<template>
	<view>
		<u-navbar :border-bottom="false" title-color="#333" title-bold title="上传成果" title-size="36"></u-navbar>
		<view class="d-id">
			
			<view class=" u-p-t-24">
				<view class="font_weight u-p-b-16">
					上传服务成果
				</view>
				
				<view class="u-m-t-10">
					<u-upload width="186" height="186" max-count="9" :form-data="formData" :max-size="1 * 1024 * 1024"
						:deletable="false" :action="action" :file-list="fileList" @on-success="onSuccess"></u-upload>
				</view>
			</view>
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="submit">
				提交
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wcshow: false,
				name: '',
				phone: '',
				list: [],
				type_id: '',
				content: '',
				// 演示地址，请勿直接使用
				action: '',
				fileList: [],
				images: [],
				formData: {
					token: uni.getStorageSync("token")
				},
				address: '',
				showsr1: false,
				
				id:"",
				
				type:''
			}
		},
		onLoad(e) {
			this.type = e.type
			this.id = e.id
			this.action = this.$config.uploadUrl
			console.log(this.action)
			// this.getType()
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			onSuccess(data, index, lists, name) {
				console.log(data)
				this.images.push(data.data.path)
			},
			
			submit() {
				if (this.images.length==0) {
					uni.showToast({
						title: "请上传图片",
						icon: "none"
					});
					return
				}
				
				let url = ""
				if(this.type = 1){
					url = '/lawyer/upload_achieve'
				}
				if(this.type = 2){
					url = '/lawyer/upload_achieve2'
				}
				this.$api({
					url: url,
					method: 'post',
					data: {
						token: uni.getStorageSync("token"),
						id:this.id,
						gallery:this.images.toString()
					},
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: "上传成功",
							icon: "none"
						});
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}
				})
			},
			
			
		}
	}
</script>

<style scoped lang="scss">
	.popupmd {
		width: 554rpx;
		// height: 344rpx;
		background: linear-gradient(180deg, #FFECEA 0%, #FFFFFF 100%);
		padding: 68rpx 24rpx;


		.p-bd {
			font-size: 28rpx;
			line-height: 64rpx;
			text-align: center;

			.p-btn2 {
				width: 248rpx;
				height: 64rpx;
				background: linear-gradient(180deg, #FA2D2D 0%, #F40000 100%);
				border-radius: 46rpx 46rpx 46rpx 46rpx;
				color: #FFFFFF;
			}
		}


	}

	.btn-bo {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0, 0, 0, 0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;

		.btn_login_btn {
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient(180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}

	.d-id {
		width: 702rpx;
		padding: 0 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 24rpx auto;

		.d-item {
			height: 100rpx;

			.d-item-t {
				width: 160rpx;
			}
		}
	}

	.textarea-d {
		width: 640rpx;
		height: 280rpx;
		background: #F8F8F8;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 24rpx;
	}
</style>